import request from '@/utils/request'
import store from '@/store'
// 新增角色户接口
export function addRole(params = {}) {
  return request({
    url: `/${store.state.user.business}/admin/role`,
    method: 'get',
    params
  })
}
// 修改角色接口
export function business(roleId, data) {
  return request({
    url: `/${store.state.user.business}/admin/role/${roleId}`,
    method: 'PUT',
    data
  })
}
export function deleterole(id, data) {
  return request({
    url: `/${store.state.user.business}/admin/role//${id}/`,
    method: 'delete',
    data
  })
}
// 查看所有菜单列表
export function getRolePreset(params) {
  return request({
    url: `/${store.state.user.business}/admin/role/get_create_role_preset/`,
    method: 'get',
    params
  })
}

// 查询角色接口
export function getRoleList(params) {
  return request({
    url: `/${store.state.user.business}/admin/role/`,
    method: 'get',
    params
  })
}

// 建立角色接口
export function creatRole(data) {
  return request({
    url: `/${store.state.user.business}/admin/role`,
    method: 'POST',
    data
  })
}

// 编辑角色接口
export function editRole(data, id) {
  return request({
    url: `/${store.state.user.business}/admin/role/${id}`,
    method: 'POST',
    data
  })
}

// 查询用户列表
export function merchantUser(params) {
  return request({
    url: `/${store.state.user.business}/admin/user/`,
    method: 'get',
    params
  })
}

// 更新用户信息
export function updateUser(data) {
  return request({
    url: `/${store.state.user.business}/admin/user/update_user_merchant_role/`,
    method: 'POST',
    data
  })
}

// 获取用户所有的角色
export function rolePreset(params) {
  return request({
    url: `/${store.state.user.business}/admin/user/get_update_user_role_preset/`,
    method: 'get',
    params
  })
}

// 获取表格字段
export function tablePreset(params = {}) {
  return request({
    url: `/${store.state.user.business}/admin/permission/get_page_key_mapper`,
    method: 'get',
    params
  })
}

export function deleteUser(id, data) {
  return request({
    url: `/${store.state.user.business}/admin/user/${id}/`,
    method: 'delete',
    data
  })
}

export function Rechargepassword( data) {
  return request({
    url: `/${store.state.user.business}/admin/user/reset/`,
    method: 'post',
    data
  })
}
